home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_200
/
233_01
/
dskrpk.c
< prev
next >
Wrap
Text File
|
1987-06-29
|
22KB
|
614 lines
/******************************************************************/
/* Directory repack */
/* written by Rich Karas for the public domain */
/* rev 1.0 1/23/86 */
/* */
/* */
/* */
/******************************************************************/
#include "stdio.h"
#include "customiz.h"
#define MAXSIZE 16383
#define MINSIZE 8192
#define MAXDIRS 512
char fat[MINSIZE];
/* these are global variables */
int drive,num_sect,begin,status,error,directory[MAXSIZE];
unsigned int fat_strt,dir_strt,data_area,dir_len;
unsigned int byte_sect,sect_unit,reserv_strt,no_fat,fat_sect,no_root;
unsigned int sect_image,media,sect_track,no_heads,no_hidden;
int *bufptr;
#define UNDERL "\033\133\064\155\0"
#define NORMAL "\033\133\155\0"
#define REVERSE "\033\133\067\155\0"
#define BOLD "\033\133\061\155\0"
#define BLINK "\033\133\065\155\0"
#define CLRSCR "\033\133\062\112\0"
#define ERASELN "\033\133\113\0"
#define XTIME 30
#define CPOS1 "\033\133\065\073\062068\110\0"
/******************************************************************/
/* */
/* Introduction is a procedure that prints using ansii */
/* ESCAPE codes to implement blinking and cusor position. */
/* */
/* */
/* */
/******************************************************************/
intro() /* introduces who we are */
{
printf("%s",CLRSCR);
printf("%s",CPOS1);
printf("%s%s DIRECTORY REPACK %s\n",BOLD,BLINK,NORMAL);
printf("\n\n\n\n\n\n");
printf(" Rich Karas\n");
printf(" 14 Wells Road\n");
printf(" Flemington,NJ 08822\n");
printf(" Voice 201-782-0639\n");
printf(" Data 201-782-7640\n");
printf("\n\n\n\n\n");
printf(" Public Domain Software 1986, Richard Karas \n");
printf(" REV 1.0 1/23/86");
sleep(XTIME);
printf("%s",CLRSCR);
}
/******************************************************************/
/* */
/* Select drive is an assembly language program which */
/* calls DOS system functions to find out how many drives */
/* are present. */
/* */
/* */
/******************************************************************/
select_drive()
{
register int x;
#asm
push ds
push ss
push ax
push dx
mov ah,19h
int 21h
mov dl,al
mov ah,0eh
int 21h
mov di,ax
pop dx
pop ax
pop ss
pop ds
#endasm
return( x & 0177);
}
/******************************************************************/
/* */
/* Reset dsk does just what it says,using */
/* another DOS system call. */
/* */
/* */
/* */
/******************************************************************/
reset_dsk()
{
#asm
push ds
push ss
push ax
push dx
mov ah,0dh
int 21h
pop dx
pop ax
pop ss
pop ds
#endasm
}
/******************************************************************/
/* */
/* Disk read performs absolute disk reads through */
/* the system calls. IT reads X number of sectors begining */
/* at sector specified. */
/* */
/* */
/******************************************************************/
disk_read() /* routine to perform absolute disk read */
{
#asm
push ds
push ax
push bx
push cx
push dx
mov ax,DS:WORD PTR drive
mov bx,offset bufptr
mov dx,[bx]
mov bx,dx
mov cx,DS:WORD PTR num_sect
mov dx,DS:WORD PTR begin
int 25h
pushf
mov DS:WORD PTR error,ax
pop ax
mov DS:WORD PTR status,ax
popf
pop dx
pop cx
pop bx
pop ax
pop ds
#endasm
}
/******************************************************************/
/* */
/* Same as read, but writes to disk. */
/* */
/* */
/* */
/* */
/******************************************************************/
disk_write() /* routine to perform absolute disk write */
{
#asm
push ds
push ax
push bx
push cx
push dx
mov ax,DS:WORD PTR drive
mov bx,offset bufptr
mov dx,[bx]
mov bx,dx
mov cx,DS:WORD PTR num_sect
mov dx,DS:WORD PTR begin
int 26h
pushf
mov DS:WORD PTR error,ax
pop ax
mov DS:WORD PTR status,ax
popf
pop dx
pop cx
pop bx
pop ax
pop ds
#endasm
}
/******************************************************************/
/* */
/* Operator enters the disk dirve to repack. */
/* */
/* */
/* */
/* */
/******************************************************************/
prompt(k) /* prompts for operator entry of drive to dir repack */
int k;
{
char j,num;
int i;
j=65;
drive=0;
printf("Please select disk drive to repack directories \n");
printf(" ");
for(i=0;i<k;i++)
{ printf(" %c",j);
j=j+1;
}
printf("\n Drive = ");
scanf("%c",&num); /* gets operator value and converts to upper */
num=toupper(num);
printf("\n\n");
i=num-65;
if(i>k) {
printf(" drive selected is not configured in system");
exit(0);
}
else
drive=i;
}
/******************************************************************/
/* This procedure analysis the media discription and */
/* performs some math. It also and displays these */
/* attributes. */
/* It reads the boot sector byte offset 11-29. */
/* */
/* */
/******************************************************************/
attrib()
{
double val1[1],val2[1],val3[1],val4[1],val5[1];
char l1[100];
int temp,i;
fat_sect=directory[11]; /* ref dos manual for explanation */
sect_track=directory[12];
no_heads=directory[13];
no_hidden=directory[14];
reserv_strt=directory[7];
m